CustomListWidget

abstract class CustomListWidget<E : CustomListWidget.Entry<*>>(client: MinecraftClient, x: Int, y: Int, width: Int, height: Int) : ClickableWidget, ParentElement

A custom list widget implementation with improved scrolling, positioning, and interaction mechanics

Author

fzzyhmstrs

Since

0.6.0

Parameters

client

MinecraftClient the client instance

x

Widgets x screen position

y

Widgets y screen position

width

Widget width in pixels

height

Widget height in pixels

Inheritors

Constructors

Link copied to clipboard
constructor(client: MinecraftClient, x: Int, y: Int, width: Int, height: Int)

Types

Link copied to clipboard
abstract class Entry<P : ParentElement>(val parentElement: P) : Element

A list entry. This is responsible for managing its own position, rendering of the list row, management of any children widgets, providing correct navigation, narration, and so on.

Properties

Link copied to clipboard
Link copied to clipboard
var message: Text
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var x: Int
Link copied to clipboard
var y: Int

Functions

Link copied to clipboard
override fun appendNarrations(builder: NarrationMessageBuilder)
Link copied to clipboard
abstract fun bottomDelta(): Int

The length in pixels that the bottom of the list is out of frame below the bottom of the widget.

Link copied to clipboard
open fun charTyped(chr: Char, modifiers: Int): Boolean
Link copied to clipboard
abstract fun contentHeight(): Int

The height of the entries in the list. If the list contains twenty 20px entries, content height is 400

Link copied to clipboard
abstract fun ensureVisible(entry: E)

Ensures that the provided entry is in frame. Implementations should scroll as needed to fully incorporate the entry into the widget frame.

Link copied to clipboard
abstract fun entryAtY(mouseY: Int): E?

The entry underneath the mouse, if any.

Link copied to clipboard
open override fun forEachChild(consumer: Consumer<ClickableWidget>)
Link copied to clipboard
open fun getBottom(): Int
Link copied to clipboard
open override fun getFocused(): Element?
Link copied to clipboard
@Nullable
open fun getFocusedPath(): GuiNavigationPath?
Link copied to clipboard
open override fun getHeight(): Int
Link copied to clipboard
open override fun getNavigationFocus(): ScreenRect
Link copied to clipboard
open override fun getNavigationPath(navigation: GuiNavigation?): GuiNavigationPath?

Return a navigation path leading through this list and to an entry, as applicable. The default implementation will likely not function properly; see DynamicListWidget for an example implementation

Link copied to clipboard
open fun getRight(): Int
Link copied to clipboard
@Nullable
open fun getTooltip(): Tooltip?
Link copied to clipboard
open override fun getType(): Selectable.SelectionType
Link copied to clipboard
open override fun getWidth(): Int
Link copied to clipboard
abstract fun handleScroll(verticalAmount: Double): Boolean

Handles a scroll input. This is scroll from a mouse, so the input should be multiplied by a factor to make scroll distance reasonable.

Link copied to clipboard
abstract fun handleScrollByBar(scrollAmount: Int): Boolean

Handles "direct" scroll input. This amount is not scaled, so the amount input should be the amount scrolled.

Link copied to clipboard

Whether the scroll bar should not render if the widget isn't hovered. Default false.

Link copied to clipboard
open fun hoveredElement(mouseX: Double, mouseY: Double): Optional<Element>
Link copied to clipboard
abstract fun inFrameEntries(): List<E>

Entries that are currently visible in the list frame. These entries will be rendered as applicable. Entries partially in frame should be included.

Link copied to clipboard
open override fun isFocused(): Boolean
Link copied to clipboard
open fun isHovered(): Boolean
Link copied to clipboard
open override fun isMouseOver(mouseX: Double, mouseY: Double): Boolean
Link copied to clipboard
open override fun isNarratable(): Boolean
Link copied to clipboard
open fun isSelected(): Boolean
Link copied to clipboard
open fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean
Link copied to clipboard
open fun keyReleased(keyCode: Int, scanCode: Int, modifiers: Int): Boolean
Link copied to clipboard
Link copied to clipboard
open override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean
Link copied to clipboard
open override fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, deltaX: Double, deltaY: Double): Boolean
Link copied to clipboard
open fun mouseMoved(mouseX: Double, mouseY: Double)
Link copied to clipboard
open override fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean
Link copied to clipboard
open override fun mouseScrolled(mouseX: Double, mouseY: Double, horizontalAmount: Double, verticalAmount: Double): Boolean
Link copied to clipboard
open fun onClick(mouseX: Double, mouseY: Double)
Link copied to clipboard
open fun onRelease(mouseX: Double, mouseY: Double)
Link copied to clipboard
open fun onReposition()

This is run when the widget is moved or resized. List elements should be repositioned when this is called.

Link copied to clipboard
fun page(up: Boolean)

"Pages" the list up or down as if Page Up/Down has been pressed.

Link copied to clipboard
open fun playDownSound(soundManager: SoundManager)
Link copied to clipboard
override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float)
Link copied to clipboard
fun rowWidth(): Int

The content width of the row, excluding padding and space for the scroll bar

Link copied to clipboard
fun rowX(): Int

The X position of the row content, after padding

Link copied to clipboard
abstract fun scrollToBottom(): Boolean

Scroll to the bottom of the list content. bottomDelta should be 0 or negative after this scroll

Link copied to clipboard
abstract fun scrollToTop(): Boolean

Scroll to the top of the list content. topDelta should be 0 after this scroll.

Link copied to clipboard
abstract fun selectableEntries(): List<E>

List entries tht are currently selectable. Hidden or otherwise disabled entries should not be counted in this list.

Link copied to clipboard
open fun setAlpha(alpha: Float)
Link copied to clipboard
open override fun setFocused(focused: Boolean)
open override fun setFocused(focused: Element?)
Link copied to clipboard
open fun setHeight(height: Int)
Link copied to clipboard
open fun setTooltip(@Nullable tooltip: Tooltip?)
Link copied to clipboard
open fun setTooltipDelay(tooltipDelay: Duration)
Link copied to clipboard
open fun setWidth(width: Int)
Link copied to clipboard
abstract fun topDelta(): Int

The length in pixels that the top of the list is out of frame above the top of the widget.